package com.guli.staservice.controller;


import com.guli.commonutils.R;
import com.guli.staservice.service.StatisticsDailyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <p>
 * 网站统计日数据 前端控制器
 * </p>
 *
 * @author LMZovo
 * @since 2022-02-24
 */
@Api(tags = "统计分析")
@RestController
@RequestMapping("/staservice/sta")
@CrossOrigin
public class StatisticsDailyController {
    @Autowired
    private StatisticsDailyService staService;

    @ApiOperation(value = "统计某一天的注册人数,生成统计数据")
    @PostMapping("registerCount/{day}")
    public R registerCount(@PathVariable("day") String day) {
        staService.registerCount(day);
        return R.ok();
    }


    @ApiOperation(value = "返回日期和数量的数据")
    @GetMapping("showData/{type}/{begin}/{end}")
    public R showData(@PathVariable("type") String type, @PathVariable("begin") String begin,
                      @PathVariable("end") String end) {
        Map<String, Object> map = staService.getShowData(type, begin, end);
        return R.ok().data(map);
    }

}